<include file="SpStore:header" />
		<!----《/头部结束》----->
		<div class="ncsc-layout wrapper">
			<include file="SpStore:goods_left" />
		<div id="layoutRight" class="ncsc-layout-right">
			<div class="ncsc-path">
				<i class="icon-desktop"></i>商家管理中心
				<i class="icon-angle-right"></i>商品
				<i class="icon-angle-right"></i>商品发布
			</div>
			<div class="main-content" id="mainContent">
				<ul class="add-goods-step">
					<li><i class="icon icon-list-alt"></i>
						<h6>STEP.1</h6>
						<h2>选择商品分类</h2>
						<i class="arrow icon-angle-right"></i> </li>
					<li><i class="icon icon-edit"></i>
						<h6>STEP.2</h6>
						<h2>填写商品详情</h2>
						<i class="arrow icon-angle-right"></i> </li>
					<li class="current"><i class="icon icon-camera-retro "></i>
						<h6>STEP.3</h6>
						<h2>上传商品图片</h2>
						<i class="arrow icon-angle-right"></i> </li>
					<li><i class="icon icon-ok-circle"></i>
						<h6>STEP.4</h6>
						<h2>商品发布成功</h2>
					</li>
				</ul>
				<form method="post" id="goods_image" action="/store/store_goods_add?op=add_step_four&commonid={$commonid}">
					<input type="hidden" name="form_submit" value="ok">
					<if condition="$goods_wts.id gt 0">
					<input type="hidden" name="st_type" value="edit">
					<input type="hidden" name="goodsid" value="{$goods_wts.id}">
					</if>
					<div class="ncsc-form-goods-pic">
						<div class="container">
							<div class="ncsc-goodspic-list" style="opacity: 1;">
								<div class="title">
									<h3>颜色：无颜色</h3></div>
								<ul nctype="ul0">

									<li class="ncsc-goodspic-upload">
										<div class="upload-thumb"><img src="/Public/Home/images/default_goods_image_240.gif" nctype="file_00">
											<input type="hidden" name="img[0][0][name]" value="" nctype="file_00">
										</div>
										<div class="show-default selected" nctype="file_00">
											<p><i class="icon-ok-circle"></i>默认主图
												<input type="hidden" name="img[0][0][default]" value="1">
											</p>
											<a href="javascript:void(0)" nctype="del" class="del" title="移除">X</a>
										</div>
										<div class="show-sort">排序：<input name="img[0][0][sort]" type="text" class="text" value="0" size="1" maxlength="1">
										</div>
										<div class="ncsc-upload-btn">
											<a href="javascript:void(0);"><span><input type="file" hidefocus="true" size="1" class="input-file" name="file_00" id="file_00"></span>
												<p><i class="icon-upload-alt"></i>上传</p>
											</a>
											<i/><i>
										</div>

									</li>
									<li class="ncsc-goodspic-upload">
										<div class="upload-thumb"><img src="/Public/Home/images/default_goods_image_240.gif" nctype="file_01">
											<input type="hidden" name="img[0][1][name]" value="" nctype="file_01">
										</div>
										<div class="show-default" nctype="file_01">
											<p><i class="icon-ok-circle"></i>默认主图
												<input type="hidden" name="img[0][1][default]" value="0">
											</p>
											<a href="javascript:void(0)" nctype="del" class="del" title="移除">X</a>
										</div>
										<div class="show-sort">排序：<input name="img[0][1][sort]" type="text" class="text" value="0" size="1" maxlength="1">
										</div>
										<div class="ncsc-upload-btn">
											<a href="javascript:void(0);"><span><input type="file" hidefocus="true" size="1" class="input-file" name="file_01" id="file_01"></span>
												<p><i class="icon-upload-alt"></i>上传</p>
											</a>
										</div>

									</li>
									<li class="ncsc-goodspic-upload">
										<div class="upload-thumb">
											<img src="/Public/Home/images/default_goods_image_240.gif" nctype="file_02">
											<input type="hidden" name="img[0][2][name]" value="" nctype="file_02">
										</div>
										<div class="show-default" nctype="file_02">
											<p><i class="icon-ok-circle"></i>默认主图
												<input type="hidden" name="img[0][2][default]" value="0">
											</p>
											<a href="javascript:void(0)" nctype="del" class="del" title="移除">X</a>
										</div>
										<div class="show-sort">排序：<input name="img[0][2][sort]" type="text" class="text" value="0" size="1" maxlength="1">
										</div>
										<div class="ncsc-upload-btn">
											<a href="javascript:void(0);"><span><input type="file" hidefocus="true" size="1" class="input-file" name="file_02" id="file_02"></span>
												<p><i class="icon-upload-alt"></i>上传</p>
											</a>
										</div>

									</li>
									<li class="ncsc-goodspic-upload">
										<div class="upload-thumb"><img src="__PUBLIC__/Home/images/default_goods_image_240.gif" nctype="file_03">
											<input type="hidden" name="img[0][3][name]" value="" nctype="file_03">
										</div>
										<div class="show-default" nctype="file_03">
											<p><i class="icon-ok-circle"></i>默认主图
												<input type="hidden" name="img[0][3][default]" value="0">
											</p>
											<a href="javascript:void(0)" nctype="del" class="del" title="移除">X</a>
										</div>
										<div class="show-sort">排序：<input name="img[0][3][sort]" type="text" class="text" value="0" size="1" maxlength="1">
										</div>
										<div class="ncsc-upload-btn">
											<a href="javascript:void(0);"><span><input type="file" hidefocus="true" size="1" class="input-file" name="file_03" id="file_03"></span>
												<p><i class="icon-upload-alt"></i>上传</p>
											</a>
										</div>

									</li>
									<li class="ncsc-goodspic-upload">
										<div class="upload-thumb"><img src="__PUBLIC__/Home/images/default_goods_image_240.gif" nctype="file_04">
											<input type="hidden" name="img[0][4][name]" value="" nctype="file_04">
										</div>
										<div class="show-default" nctype="file_04">
											<p><i class="icon-ok-circle"></i>默认主图
												<input type="hidden" name="img[0][4][default]" value="0">
											</p>
											<a href="javascript:void(0)" nctype="del" class="del" title="移除">X</a>
										</div>
										<div class="show-sort">排序：<input name="img[0][4][sort]" type="text" class="text" value="0" size="1" maxlength="1">
										</div>
										<div class="ncsc-upload-btn">
											<a href="javascript:void(0);"><span><input type="file" hidefocus="true" size="1" class="input-file" name="file_04" id="file_04"></span>
												<p><i class="icon-upload-alt"></i>上传</p>
											</a>
										</div>

									</li>
								</ul>
								<div class="ncsc-select-album">
									<a class="ncsc-btn selected" href="#" id="select-0" ><i class="icon-picture"></i>从图片空间选择</a>
									<a href="javascript:void(0);" id="close_album" class="ncsc-btn ml5"><i class=" icon-circle-arrow-up"></i>关闭相册</a>
								</div>
								<div id="album-0">

								</div>
							</div>
						</div>
						<div class="sidebar">
							<div class="alert alert-info alert-block" id="uploadHelp">
								<div class="faq-img"></div>
								<h4>上传要求：</h4>
								<ul>
									<li>1. 请使用jpg\jpeg\png等格式、单张大小不超过1M的正方形图片。</li>
									<li>2. 上传图片最大尺寸将被保留为1280像素。</li>
									<li>3. 每种颜色最多可上传5张图片或从图片空间中选择已有的图片，上传后的图片也将被保存在店铺图片空间中以便其它使用。</li>
									<li>4. 通过更改排序数字修改商品图片的排列显示顺序。</li>
									<li>5. 图片质量要清晰，不能虚化，要保证亮度充足。</li>
									<li>6. 操作完成后请点下一步，否则无法在网站生效。</li>
								</ul>
								<h4>建议:</h4>
								<ul>
									<li>1. 主图为白色背景正面图。</li>
									<li>2. 排序依次为正面图-&gt;背面图-&gt;侧面图-&gt;细节图。</li>
								</ul>
							</div>
						</div>
					</div>
					<div class="bottom tc hr32"><label class="submit-border"><input type="submit" class="submit" value="下一步，确认商品发布"></label></div>
				</form>

			</div>
		</div>
		<script type="text/javascript">
		var state = 'img';
		var $this =$("[nctype='ul0'] li");
		
		$("[nctype='del']").live('click',function(){
				var val = $(this).attr('nctype');
				var img = '/Public/Home/images/default_goods_image_240.gif';
				var imput =$(this).parent().parent().find('[class="upload-thumb"]').children('input').val();
				var state = 'img_del';
				//alert(imput);	
				if(val=='del' && imput){								
					$(this).parent().parent().find('[class="upload-thumb"]').children('img').attr('src',img);
					$(this).parent().parent().find('[class="upload-thumb"]').children('input').val('');
					//修改图片
					var $this =$(this);
					getimg(state,$this);				
				}
				
		});
		
		getimg(state,$this);
		
		//图片
		function getimg(state,$this){
			var url='/store/eachimg';		
			$.ajax({
				url:url,
				data:{nctype:state},
				type:'get',
				dataType:'json',
				success:function (e) {
					var html = '';
					
					var data = e.img;
					
					if (e.info==1) {
						$this.find('div img[nctype="file_00"]').attr('src',e.img);
						$this.find('div img[nctype="file_00"]').next('input').val(e.img);
					} else if(e.info==2){
									
						for(var i=0;i<=data.length;i++){
							
							$("[class='upload-thumb'] input").each(function(){
								var vals = $(this).val();
																
								if (!vals) {
									$(this).val(data[i].name);
									$(this).parent().find('img').attr('src',data[i].name);
									//alert(data[i].name);
									return false;	
								} 
										 
							});									
						}					
					}
												
				}
			});			
		}
			
		</script>
					<script type="text/javascript">
						function uploadImage(fileid) {
						    var data = new FormData();
							$.each(fileid[0].files, function(i, file) {
								 data.append('upload_file', file);
							 });
							 data.append('store', 1);

							$.ajax({
								type: "POST",
								url: "/store/pic_upload",
								data: data,
								contentType:'multipart/form-data',
								cache: false,
								contentType: false,    //不可缺
								processData: false,    //不可缺
								success: function(data) {
									//alert(data.info);
									fileid.parent().parent().parent().parent().find('[class="upload-thumb"]').children('img').attr('src',data.info);
									
									fileid.parent().parent().parent().parent().find('[class="upload-thumb"]').children('input').val(data.info);

									
								}
							});
						}
								
						//上传图片
						$("[class='ncsc-upload-btn'] [type='file']").live('change',function(){
							var file =$(this) ; 
							uploadImage(file);
								
						});
						
						$('#close_album').hide();
						$('#select-0').live('click',function() {
						//alert(11);
								var state = 'show_image';
								$('#select-0').hide();
								$('#close_album').show();
								imgset(state);								
								$("#album-0").show();
							}); 
	
							$('#close_album').live('click',function() {

								$('#select-0').show();
								$('#close_album').hide();
								$("#album-0").hide();
							}); 

							//获取图片 上传一次刷新一次
							function imgset(state) {
								$.ajax({
									type: "POST",
									url: "/store/picset",
									data:{state:state},
									dataType:'json',
									success: function(data) {
										var e = data.length;
										var id ='';
										if (state=='show_image'){
											id = 'demo_image';
										} else if(state=='show_desc') {
											id = 'g_body';
										}
										//alert(id);
										var html = '<div class="goods-gallery" nctype="gallery-0"><a class="sample_demo" href="#" style="display:none;">提交</a><div class="nav"><span class="l">用户相册 &gt;全部图片</span><span class="r"><select name="jumpMenu" style="width:100px;"><option value="0" style="width:80px;">请选择...</option><option style="width:80px;" value="2">默认相册</option></select></span></div><ul class="list" id="list_li">';
										
										for(var i=0;i<e;i++){
											html += '<li><a href="JavaScript:void(0);" data_pid ="'+id+'" ><img src="'+data[i]+'" title="bobo_logo"></a></li>';
											
										}
										html += '</ul><div class="pagination"><ul><li><span>首页</span></li><li><span>上一页</span></li><li><span class="currentpage">1</span></li><li><span>下一页</span></li><li><span>末页</span></li></ul></div></div>';
										if (state=='show_image') {
											$("#album-0").html(html);
										}
									}
								});								
							}
								//选择图片
								$("#list_li li a").live('click',function(){
									var pid = $(this).attr('data_pid');
									var img = $(this).find('img').attr('src');
									 $("[class='upload-thumb'] input").each(function(){
										
										 var vals = $(this).val();
										 if (!vals) {
											$(this).val(img);
											$(this).parent().find('img').attr('src',img);
											return false;
										 }
										 //alert(vals);
									});							
														
								}); 
						
								
					</script>

		<!--底部-->

	<include file="SpStore:footer" />
	</body>

</html>